package com.zybzzz.workapp.entry;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Project Name：workapp
 * Class Name：SinglePlanDateLab
 * description： 存储日期计划数据的单例类
 * Date：2020-10-23 19:34
 * author：zhangyibo
 */
public class SinglePlanDateLab {

    private static SinglePlanDateLab singlePlanDateLab;

    //数据存储在map
    private List<PlanDate> planDateList;


    /**
     * @name: get
     * @description: 静态方法用于获取单例，进而获取容器
     * @return: com.zybzzz.workapp.entry.SinglePlanDateLab
     * @date: 2020-10-23 19:38
     * @auther: zhangyibo
     *
    */
    public static SinglePlanDateLab get(){
        if (singlePlanDateLab==null){
            return singlePlanDateLab=new SinglePlanDateLab();
        }else {
            return singlePlanDateLab;
        }
    }

    /**
     * @name: SinglePlanDateLab
     * @description: 私有构造函数给静态方法调用 用于创建单例
     * @return:
     * @date: 2020-10-24 08:22
     * @auther: zhangyibo
     *
    */
    private SinglePlanDateLab(){
        planDateList=new ArrayList<>();
    }

    /**
     * @name: getPlanDateList
     * @description: 直接获取所有小计划的信息 不建议使用 没有使用场景
     * @return: java.util.List<com.zybzzz.workapp.entry.PlanDate>
     * @date: 2020-10-24 08:24
     * @auther: zhangyibo
     *
    */
    @Deprecated
    public List<PlanDate> getPlanDateList() {
        return planDateList;
    }


    /**
     * @name: filterPlanByDate
     * @description: 根据日期将列表中的信息放在容器中返回
     * @param date
     * @return: java.util.List<com.zybzzz.workapp.entry.PlanDate>
     * @date: 2020-10-24 08:28
     * @auther: zhangyibo
     *
    */
    public List<PlanDate> filterPlanByDate(String date){
        List<PlanDate> filterPlanList=new ArrayList<>();
        for (PlanDate planDate : planDateList) {
            if (planDate.getFinishDate().trim().equals(date.trim())){
                filterPlanList.add(planDate);
            }
        }
        return filterPlanList;
    }

    /**
     * @name: addPlanDate
     * @description: 对外提供增加信息的接口
     * @param planDate
     * @return: void
     * @date: 2020-10-24 09:27
     * @auther: zhangyibo
     *
    */
    public void addPlanDate(PlanDate planDate){
        this.planDateList.add(planDate);
    }
}
